<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>${title}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }

        .nav {
            margin-bottom: 20px;
        }

        .nav a {
            margin-right: 15px;
            text-decoration: none;
            color: #0066cc;
        }

        .content {
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 15px;
        }

        th, td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #f8f9fa;
        }

        .actions a {
            margin-right: 10px;
            text-decoration: none;
        }

        .message {
            color: #28a745;
            padding: 10px;
            background-color: #d4edda;
            border: 1px solid #c3e6cb;
            border-radius: 5px;
            margin-bottom: 15px;
        }

        .error {
            color: #dc3545;
            padding: 10px;
            background-color: #f8d7da;
            border: 1px solid #f5c6cb;
            border-radius: 5px;
            margin-bottom: 15px;
        }

        .btn {
            display: inline-block;
            padding: 6px 12px;
            background-color: #007bff;
            color: white;
            text-decoration: none;
            border-radius: 4px;
            border: 1px solid #007bff;
        }

        .btn:hover {
            background-color: #0069d9;
        }
    </style>
</head>
<body>
<div class="nav">
    <a href="${pageContext.request.contextPath}/">首页</a>
    <a href="${pageContext.request.contextPath}/about">关于我们</a>
    <a href="${pageContext.request.contextPath}/users">用户管理</a>
</div>

<div class="content">
    <h1>${title}</h1>

    <c:if test="${not empty message}">
        <div class="message">${message}</div>
    </c:if>

    <c:if test="${not empty error}">
        <div class="error">${error}</div>
    </c:if>

    <p><a href="${pageContext.request.contextPath}/users/new" class="btn">创建新用户</a></p>

    <table>
        <tr>
            <th>ID</th>
            <th>用户名</th>
            <th>邮箱</th>
            <th>操作</th>
        </tr>
        <c:forEach var="user" items="${users}">
            <tr>
                <td>${user.id}</td>
                <td>${user.username}</td>
                <td>${user.email}</td>
                <td class="actions">
                    <a href="${pageContext.request.contextPath}/users/${user.id}">查看</a>
                    <a href="${pageContext.request.contextPath}/users/${user.id}/edit">编辑</a>
                    <a href="${pageContext.request.contextPath}/users/${user.id}/delete"
                       onclick="return confirm('确定要删除用户 ${user.username} 吗？')">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>
